package com.zly.bscloud.controller;

import com.zly.bscloud.dto.SiteDTO;
import com.zly.bscloud.entity.Site;
import com.zly.bscloud.service.SiteService;
import com.zly.bscloud.utils.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zhouxiaoyu
 * @Date 2020/5/26 22:05
 * @Version 1.0
 */
@RestController
@RequestMapping("/site")
@CrossOrigin
public class SiteController {
    @Autowired
    public SiteService siteService;

    @PostMapping("/save-site")
    public Result saveSite(@RequestBody Site site){
        //System.out.println(site);
        SiteDTO sitenew=siteService.saveSite(site);
        return Result.createSuccess(sitenew);
    }

    @GetMapping("/get-sites/{user_id}")
    public Result getSiteList(@PathVariable("user_id") String user_id){

        List<SiteDTO> siteDTOList = siteService.getSiteList(user_id);
        //System.out.println(siteDTOList);
        return Result.createSuccess(siteDTOList);
    }

    @GetMapping("/get-siteone/{id}")
    public Result getSiteone(@PathVariable("id") String id){
        System.out.println(111);
        SiteDTO siteDTO = siteService.getSiteone(id);
        System.out.println(siteDTO);
        return Result.createSuccess(siteDTO);
    }
}
